GBML manual / Drawing

sprite_blocky

Marks everything this object draws as blocky, or takes the mark off, so a look from screen_mosaic can turn it into big square blocks: a hero that comes into focus. on is true to mark it and false to take the mark off. With no mosaic look on, a marked object looks just the way it did.

Works differently on Game Boy - The Game Boy marks the sprite as blocky; as on the Game Boy Advance a mark alone changes nothing, the block size comes from a sprite effect, and the sprite is drawn as a picture made ahead of time in blocks of the nearest size.

Works differently on Game Boy Color - The Game Boy Color marks the sprite as blocky; as on the Game Boy Advance a mark alone changes nothing, the block size comes from a sprite effect, and the sprite is drawn as a picture made ahead of time in blocks of the nearest size.

Sega Genesis: not available

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

sprite_blocky(on)

Arguments

NameType
onbool

Returns

Nothing.

Description

Marks everything this object draws as blocky, or takes the mark off again. A marked object is drawn in big square blocks while a mosaic look is on, and screen_mosaic decides how big the blocks are on each row. It is how a hero comes into focus, or turns into big pixels when it is hit.

A real capture, two pictures of the same pine forest at dusk with a striped lighthouse on the left and a yellow slab with the word PIX on the right, while a MOSAIC_BLOCKS look is on - in the first both are sharp, because they are not marked; in the second both are marked blocky and are drawn in square blocks 8 pixels across, while the forest stays sharpA real capture, two pictures of the same pine forest at dusk with a striped lighthouse on the left and a yellow slab with the word PIX on the right, while a MOSAIC_BLOCKS look is on - in the first both are sharp, because they are not marked; in the second both are marked blocky and are drawn in square blocks 8 pixels across, while the forest stays sharp
A real capture, two pictures of the same pine forest at dusk with a striped lighthouse on the left and a yellow slab with the word PIX on the right, while a MOSAIC_BLOCKS look is on - in the first both are sharp, because they are not marked; in the second both are marked blocky and are drawn in square blocks 8 pixels across, while the forest stays sharp

A mosaic look is on in both pictures. Left: nothing is marked, so everything is sharp. Right: the lighthouse and the slab are marked, so they turn into blocks, and the forest, which is not marked, stays sharp. The lighthouse is drawn by the engine for the object; the slab and its word are drawn by an object's Draw event. Real pictures from a Game Boy Advance ROM.

You give it one thing:

It belongs to the object that calls it, so there is no handle to keep: write sprite_blocky(true) in the object's own event and it is that object that is marked.

On its own it changes nothing you can see

A marked object looks exactly the way it did until a mosaic look is on. The mark only says "this one may be blocky". It is screen_mosaic that decides how big the blocks are, row by row.

Everything the object draws

The mark covers everything the object draws: the picture the engine draws for it by itself, and whatever its Draw event draws (draw_self, draw_sprite, draw_text, draw_rect_fill and the rest, text included). A picture the engine lets go of and makes again is marked again the same frame.

How the blocks sit

Each block is one pixel of the picture, made big: the color of the pixel in the block's top left corner. The blocks are laid on the screen, from its top left corner, not on the picture. So a picture that moves slides through the grid, and its blocks change as it moves. At the picture's own edges a block can be cut (the first block takes the picture's edge pixel), and the last block along the right edge can stick out a few pixels past the picture. A picture that is lined up with the grid (its top left corner on a multiple of 16) has whole blocks all the way round.

What it costs

No row-by-row slot and no matrix. A project that never calls sprite_blocky or sprite_see_through keeps none of the code. A project that does keeps a small table for up to 32 objects marked at once (about 1 KB of the console's big, slow memory), and once a frame it writes the flag on the pictures of every marked object. Measured on a real ROM, with 32 objects each drawing a rectangle: the first marked object costs about 2 hundredths of a frame (that is the pass over everything the game has drawn), 8 marked objects about 4 hundredths, and all 32 about 8 hundredths.

Marking a 33rd object, or calling it where there is no object (a room's creation code, a script), does not just do nothing: a development build stops with a message that says what is wrong, and a release build marks nothing.

Turning it off

Call sprite_blocky(false); and the flag comes off the object's pictures at once. When the object is destroyed or its room ends, its mark ends by itself.

Example

sprite_blocky(true);
screen_mosaic(MOSAIC_BLOCKS, 3, 0);

An object that turns into big blocks. Call it in the object's Create event.

if (btn_pressed(BTN_A)) {
    sprite_blocky(true);
}

if (btn_pressed(BTN_B)) {
    sprite_blocky(false);
}

Pressing A marks the object so a mosaic look reaches it; pressing B takes the mark off. Pressing A again changes nothing, because the object is already marked.

draw_rect_fill(x - 32, y - 36, 64, 72, COLOR_YELLOW);
draw_text(x, y, "PIX");

An object with a Draw event that draws a slab and a word. If the object is marked, both turn into blocks together.

On the GBA

Costs no row-by-row slot and no matrix. It marks everything the object draws: the picture the engine draws for it by itself, and whatever its Draw event draws (sprites, text, rectangles). It keeps a small record for the object, up to 32 objects at a time, in 640 bytes of the console’s big, slow memory (EWRAM) that a project which never calls it does not have, and once a frame it sets the console’s mosaic flag on each of the object’s pictures; a picture the engine lets go of and makes again gets its flag again the same frame. The console makes a marked picture blocky with the block size screen_mosaic sets row by row; with no mosaic look the block size is one pixel, so nothing changes. The mark stays until you turn it off or the object is destroyed. Call it from the object’s own event, once: the Create event is the place. An event the object has from a parent cannot find its pool unless the code names the child, and a call that finds no object (a room’s creation code, a script) is refused. Marking a 33rd object is refused too: a development build stops with a message, a release build marks nothing.

See also: screen_mosaicsprite_see_throughbackground_blockysprite_warpdraw_spritedraw_text